home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Networking / SNMP / SNMP Development / MacSNMP Developer 1.0.2 / SNMP Interfaces / TSNMP.h < prev   
Encoding:
C/C++ Source or Header  |  1993-06-15  |  6.9 KB  |  237 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        TSNMP.h
  3.  
  4.     Contains:    SNMP Class declarations
  5.     
  6.     Copyright:    © 1991-1992 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9. #ifndef __TSNMP__
  10. #define __TSNMP__
  11.  
  12.  
  13. /**********************************************************************
  14. **    Includes
  15. **********************************************************************/
  16.  
  17. #ifndef __LIBRARYMANAGER__
  18. #include <LibraryManager.h>
  19. #endif
  20.  
  21. #ifndef __SNMP__
  22. #include <SNMP.h>
  23. #endif
  24.  
  25. #ifndef __MEMORY__
  26. #include <Memory.h>
  27. #endif
  28.  
  29. #ifndef __ALIASES__
  30. #include <Aliases.h>
  31. #endif
  32.  
  33. /**********************************************************************
  34. ** Class Definitions
  35. ***********************************************************************/
  36.  
  37. // structure type references
  38.  
  39. class TSNMPAgent;
  40. class TSNMPVar;
  41. class TSNMPManagerPrv;
  42. class TSNMPMIBNode;
  43.  
  44. /**********************************************************************
  45. ** Library IDs
  46. ***********************************************************************/
  47. #define kLIB_SNMPID     "snmp:mgr$"
  48. #define kLIB_AgentID "snmp:agt$"
  49.  
  50. /**********************************************************************
  51. ** Class IDs
  52. ***********************************************************************/
  53. #define kTSNMPManagerID     "snmp:mgr$TSNMPManager"
  54. #define kTSNMPConsoleID        "snmp:mgr$TSNMPConsole"
  55. #define kTSNMPAgentID         "snmp:mgr$TSNMPAgent"
  56. #define kTSNMPVarID         "snmp:mgr$TSNMPVar"
  57. #define kTDevSNMPVarID         "snmp:mgr$TDevSNMPVar"
  58.  
  59. /**********************************************************************
  60. ** Class TSNMPManager. Don't subclass, use TSNMPAgent::fSNMPManagerPtr.
  61. ***********************************************************************/
  62.  
  63. class TSNMPManager : public TDynamic
  64. {
  65. public:
  66.                     TSNMPManager();
  67.     virtual            ~TSNMPManager();
  68.         
  69. // Agent routines
  70.  
  71.     virtual OSErr    AddGroup(
  72.         TSNMPAgent*        theAgentPtr,             // who wants to give a group name to a subtree
  73.         ObjectIDPtr        theGroupIdPtr,             // all ids below this show up inside the group
  74.         StringPtr        theGroupNamePtr,        // the name that shows in the UI
  75.         short            descResID,                // resource id of description resource
  76.         short            descStrIndex ) = 0;        // index of desc string in desc string STR# resource
  77.  
  78.     virtual OSErr    SendTrap(
  79.         SNMPTrapCode    generic,                 // values defined in the SMI (RFC 1155) 
  80.         short            specific,                 // developer defined error extensions
  81.         ObjectIDListPtr    idListPtr ) = 0;        // variables sent in the trap packet
  82.  
  83. // Variable routines        
  84.  
  85.     virtual OSErr    AddMIBVar(                     // must InitTSNMPVar() first
  86.         TSNMPVar*     theVarPtr,                    // the variable to add
  87.         StringPtr    varNamePtr) = 0;            // the name that shows in the UI
  88.  
  89.     virtual OSErr    GetVariableInfo(
  90.         ObjectIDListPtr idListPtr,                 // unique specifiers for a set of variables        
  91.         short             next,                    // a powerful get-next request?
  92.         Ptr                mibletBufferPtr,        // description and value of the variables
  93.         Size            bufferSize ) = 0;        // how much space available in miblet buffer
  94.         
  95. // Registration completion notification
  96.  
  97.     virtual OSErr    RegisterDone(
  98.         TSNMPAgent*        agent) = 0;                // the agent which has completed registration
  99.  
  100.  
  101. // interface routine
  102.  
  103.     virtual unsigned long GetIFindex(            // used by agents to get the if index of
  104.         short            description,            // Network devices 
  105.         char            location) = 0;            // descriptions & locations are found in SNMP.h
  106.                                                 
  107. };
  108.  
  109.  
  110. /**********************************************************************
  111. ** Class TSNMPAgent 
  112. ***********************************************************************/
  113.  
  114. class TSNMPAgent: public TDynamic
  115. {
  116. public:
  117.                     TSNMPAgent();                // fills in fSNMPManager
  118.     virtual            ~TSNMPAgent();        
  119.     
  120.     virtual    OSErr    InitSNMPAgent(    
  121.         StringPtr    agentNamePtr,                // name of the agent that shows in the UI
  122.         short        descResID,                    // resource id of description STR#
  123.         short        descStrIndex,                // index in description STR# of agent description
  124.         short        agentVersion);                // version # of the agent -- values 0 and all negative 
  125.                                                 // values are reserved
  126.  
  127.     virtual OSErr    GetAgentFSSpec( 
  128.         FSSpec *aFSSpecPtr);                    // where variable descriptions are kept
  129.                                         
  130. friend TSNMPManagerPrv;
  131.     
  132. protected:
  133.     TSNMPManager*    fSNMPManagerPtr;            // for SNMPManager calls described above
  134.     TLibraryFile*    fAgentLibraryPtr;
  135.     
  136. private:
  137.     char            fAgentName[33];
  138.     short            fDescResID;                    
  139.     short            fDescStrIndex;
  140.     short            fAgentVersion;
  141. };
  142.  
  143.  
  144. /**********************************************************************
  145. ** Class TSNMPVar 
  146. ***********************************************************************/
  147.  
  148. class TSNMPVar : public TDynamic
  149. {
  150. public:
  151.                     TSNMPVar();
  152.     virtual            ~TSNMPVar();            
  153.     
  154.     virtual    OSErr    InitSNMPVar(                // must call inherited if overridden
  155.         TSNMPAgent*        agentPtr,                // agent that implements this variable
  156.         ObjectIDPtr     idPtr,                    // varible's object ID
  157.         short            precedence,                // lowest precedence gets priority
  158.         ASNTagType        type,                    // describes variable's encoding
  159.         SMIAccess        access,                    // maximum access allowed
  160.         short            descResID,                // resource id of description  STR# resource
  161.         short            descStrIndex);            // index of description string in STR# resource
  162.                                 
  163.     TSNMPAgent*            GetAgentPtr();        
  164.     
  165. friend TSNMPManagerPrv;
  166. friend TSNMPMIBNode;
  167. friend TSNMPPrefixNode;
  168. friend TSNMPEndNode;
  169.     
  170. private:
  171.  
  172.     virtual ObjectIDPtr    GetIDPtr();                
  173.  
  174.     ObjectIDPtr        fIDPtr;                            
  175.     TSNMPAgent*        fAgentPtr;
  176.     short            fPrecedence;
  177.     ASNTagType        fType;
  178.     SMIAccess        fAccess;
  179.     short            fDescResID;
  180.     short            fDescStrIndex;
  181.     long            fCommunities;
  182.     TSNMPMIBNode    *fParentNode;
  183.     unsigned long    fSubID;
  184.     
  185. };
  186.  
  187. /**********************************************************************
  188. ** Inline Member Functions
  189. ***********************************************************************/
  190.  
  191. inline TSNMPAgent*
  192. TSNMPVar::GetAgentPtr() { return fAgentPtr; }
  193.  
  194.  
  195. /**********************************************************************
  196. ** Class TDevSNMPVar must be subclassed by developers for their variables
  197. ***********************************************************************/
  198.  
  199. class TDevSNMPVar : public TSNMPVar
  200. {
  201. public:
  202.                     TDevSNMPVar();
  203.     virtual            ~TDevSNMPVar();            
  204.                                 
  205.     virtual OSErr    GetVariable( 
  206.         Boolean            next,                // if true then it is a get next request
  207.         ObjectIDPtr     varOIDPtr,             // unique id for variable    
  208.         VarBuf*            valuePtr ) = 0;        // where to place the value returned
  209.                 
  210.     virtual OSErr    SetVariable( 
  211.         ObjectIDPtr     varOIDPtr,             // unique id for variable
  212.         VarBuf*         valuePtr,             // value to set variable to
  213.         SetStage         action ) = 0;        // for 'simultaneous' sets
  214. };
  215.  
  216.  
  217.  
  218. /**********************************************************************
  219. ** Class TSNMPConsole must be subclassed by developers for a console
  220. ***********************************************************************/
  221.  
  222. class TSNMPConsole : public TDynamic
  223. {
  224. public:
  225.                     TSNMPConsole();
  226.     virtual            ~TSNMPConsole();
  227.                     
  228.     virtual OSErr    ReceiveRawPacket(                    // must override
  229.                         PacketPiecePtr    packetPtr,         // raw SNMP Trap packet
  230.                         TIAddressPtr     source);        // where the packet came from 
  231.  
  232. private:
  233.     TSNMPManager*    fSNMPManagerPtr;                    // Pointer to the manager
  234.     SNMPRefNum*        fConsoleInfoPtr;                    // Pointer to console info
  235. };
  236.  
  237. #endif __TSNMP__